<?php

use yii\helpers\Html;
use yii\widgets\Pjax;
use yii\bootstrap\Modal;
use kartik\select2\Select2;
use app\common\Functions;

/* @var $this  yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */

$this->title = Yii::t('region', 'Create RegionType');
//$this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', 'Rules'), 'url' => ['index']];
//$this->params['breadcrumbs'][] = $this->title;
//$this->render('/layouts/_sidebar');
?>




<div class="rule-item-create" style="min-height: 1126px;">
    <style>
        .table thead>tr>th, .table thead>tr>td .form-control,.table tbody>tr>th, .table tfoot>tr>th, .table thead>tr>td, .table tbody>tr>td, .table tfoot>tr>td, .table thead>tr>td input{font-size:12px;line-height:24px;padding:3px;height:24px;},

    </style>
    <section class="content">


        <div class="row">

            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#buildingmng" data-toggle="tab" aria-expanded="true">楼宇管理</a></li>
                        <?php if($yw2!==2 && $parent_prod_id && $prod_spec_id==10002):?>
                        <li class=""><a class="tbcust-mng-tabs" id="tbcust-tabs" href="#tbcustmng" data-toggle="tab" aria-expanded="false">招商管理</a></li>
                        <?php  endif;?>
<!--                        <li class=""><a class="tborder-log-tabs" id="tborder-log-tabs" href="#timeline"  data-prod-id="--><?//= $parent_prod_id ?><!--" data-toggle="tab" aria-expanded="false">跟进记录</a></li>-->
<!--                        <li class=""><a href="#info" data-toggle="tab" aria-expanded="false">楼盘详情</a></li>-->

                    <?php  $url=Yii::$app->request->getUrl(); //echo $url //URL数据?>
                        <span style="display: none;"  id="yw2"><?php  echo $yw2 ?></span>

                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="buildingmng">

                            <?php
                            if ($prod_spec_id==10002 && $state==1001 ){

                                echo $this->render('buildingmng_head', [
                                    'buildingInfo' => $buildingInfo,
                                    'totalProd' =>'1001',
                                    'yw2'=>$yw2,
                                    'whereQuery'=>$whereQuery,
                                    'dataProvider' => $dataProvider,
                                    'prod_spec_id' => $prod_spec_id,
                                    'model_mng'=>$model_mng,

                                ]);
                            }else{
                                echo $this->render('buildingmng_head', [
                                    'buildingInfo' => $buildingInfo,
                                    'totalProd' =>'1002',
                                    'yw2'=>$yw2,
                                    'whereQuery'=>$whereQuery,
                                    'dataProvider' => $dataProvider,
                                    'prod_spec_id' => $prod_spec_id,
                                    'model_mng'=>$model_mng,

                                ]);
                            }

                            // 如果已经到了房源层级则不显示列表，而是按照楼层分开展示，数据在控制器处进行汇总

                            if ($prod_spec_id==10002){

                                echo $this->render('buildingmng_floor',  [
                                    'whereQuery'=>$whereQuery,
                                    'yw2'=>$yw2,
                                    'commonality'=>$commonality,
                                    'en_now_url'  => $en_now_url,
                                    'now_url'  => $now_url,
                                    'url'=>$url,
                                    'domains'=>$domains,
                                    'customs'=>$customs,
                                    'allFloors' => $allFloors,
                                    'domainTypes' => $domainTypes,
                                    'sub_prod_spec_id' => $sub_prod_spec_id,
                                    'sub_prod_id' => $sub_prod_id,
                                    'parent_prod_id' =>$parent_prod_id,
                                    'prod_spec_id' => $prod_spec_id,
                                    'prodSpecName' =>$prodSpecName,
                                    'regionTypes' => $regionTypes,
                                    'dataProvider' => $dataProvider,
                                    'searchModel' =>  $searchModel,
                                    'regionCnt' => $regionCnt,
                                    'attrSpecs' => $attrSpecs,
                                    'regionTodayCnt' => $regionTodayCnt,
                                    'model_staff_name'=>$model_staff_name,
                                    'model_region'=>$model_region,
                                    ]);

                            }else{
                                echo $this->render('buildingmng_context',  [
                                    'customs'=>$customs,
                                    'yw2'=>$yw2,
                                    'en_now_url'  => $en_now_url,
                                    'now_url'  => $now_url,
                                    'url'=>$url,
                                    'domainTypes' => $domainTypes,
                                    'sub_prod_spec_id' => $sub_prod_spec_id,
                                    'sub_prod_id' => $sub_prod_id,
                                    'parent_prod_id' =>$parent_prod_id,
                                    'prod_spec_id' => $prod_spec_id,
                                    'prodSpecName' =>$prodSpecName,
                                    'regionTypes' => $regionTypes,
                                    'dataProvider' => $dataProvider,
                                    'searchModel' =>  $searchModel,
                                    'regionCnt' => $regionCnt,
                                    'attrSpecs' => $attrSpecs,
                                    'regionTodayCnt' => $regionTodayCnt]);
                            }

                            ?>

                        </div>
                        <div class="tab-pane" id="tbcustmng" url-data="time">


                        </div>

                        <div class="tab-pane" id="timeline">
                            <!-- The timeline -->
                            <ul class="timeline timeline-inverse">
                                <!-- timeline time label -->


                            </ul>
                        </div>
                        <div class="tab-pane" id="info">
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </section>
</div>


<?php

$js = <<<JS
jQuery('.activity-create-prod-link').on('click',function() {
     
    
    $('.document-nav-create-prod-form').remove();
     $('.document-nav-update-prod-form').remove();
    
    $.get(
        '/prod/prodinst/create',
        {
    
            prod_spec_id: $(this).data('prod_spec_id'),
            prod_spec_name: $(this).data('prod_spec_name'),
            last_url: $(this).data('last_url'),
            parent_prod_id: $(this).data('parent_prod_id'),
            yw2:$('#yw2').html()
        },
        function (data) {
            $('#create-prod-modal').find('.modal-dialog').html(data);
        }
    );
});
JS;
$this->registerJs($js);


//业务2部创建房源按钮的ajax
$js = <<<JS
jQuery('.created-prod-link').on('click',function() {


    $('.document-nav-create-prod-form').remove();
     $('.document-nav-update-prod-form').remove();

    $.get(
        '/prod/prodinst/create2',
        {

            prod_spec_id: $(this).data('prod_spec_id'),
            prod_spec_name: $(this).data('prod_spec_name'),
            last_url: $(this).data('last_url'),
            parent_prod_id: $(this).data('parent_prod_id'),
            yw2:2
        },
        function (data) {
            $('#created-prod-modal').find('.modal-dialog').html(data);
        }
    );
});
JS;
$this->registerJs($js);


//编辑
$js = <<<JS
$.fn.modal.Constructor.prototype.enforceFocus = function () { }
jQuery('.activity-update-prod-link').on('click',function() {
    $('.document-nav-update-prod-form').remove();
    $('.document-nav-create-prod-form').remove();
    $.get(
        '/prod/prodinst/update',
        {
            id: $(this).data('prod_id'),
            prod_spec_id: $(this).data('prod_spec_id'),
            prod_spec_name: $(this).data('prod_spec_name'),
            last_url: $(this).data('last_url'),
            yw2:$('#yw2').html()
        },
        function (data) {
            $('#update-prod-modal').find('.modal-dialog').html(data);
        }
    );
});
JS;
$this->registerJs($js);


//房源跟新进度
//$js = <<<JS
//jQuery('.activity-handling-resumes-link').on('click',function() {
//    $('.document-handling-resumes-form').remove();
//    $.get(
//        '/prod/order/handling',
//        {
//            order_id: $(this).data('order-id') ,
//             last_url: $(this).data('last_url')
//        },
//        function (data) {
//            $('.modal-dialog').html(data);
//            $('#handling-resumes-modal').modal();
//        }
//    );
//});
//JS;
//$this->registerJs($js);


// 导入招商管理

if($parent_prod_id){
$js = <<<JS
    jQuery('.tbcust-mng-tabs').on('click',function() {

        $('.document-tbcust-mng').remove();
        $.get(
            '/prod/cust/custsgrid',
            {
                object_id: $(this).data('prod-id'),
                parent_id: $parent_prod_id
            },
            function (data) {
                $('#tbcustmng').html(data);
            }
        );
    });
JS;
$this->registerJs($js);
};



// 导入时间线
$js = <<<JS
jQuery('.tborder-log-tabs').on('click',function() {
 
$('.document-tborder-log').remove();
$.get(
'/prod/order/prodorder',
{
object_id: $(this).data('prod-id'),
},
function (data) {
$('#timeline').html(data);
  
}
);
});
JS;
$this->registerJs($js);


// 自动调宽楼盘的尺寸
$js = <<<JS
jQuery('.tb-one-room').on('mouseenter',function() {
    
    $(this).stop();
    var index  = $(this).prevAll().size()
    if (index==11|| index==10){
        $(this).prev().animate({width:"20px"});
        $(this).prev().prev().animate({width:"20px"});
        $(this).prev().prev().prev().animate({width:"20px"});
    }
    
    $(this).animate({width:"250px"});
});

jQuery('.tb-one-room').on('mouseleave',function() {
    $(this).stop();
   
    var index  = $(this).prevAll().size()
    if (index==11 || index==10){
        $(this).stop();
        $(this).prev().removeAttr("style");
        $(this).stop();
        $(this).prev().prev().removeAttr("style");
        $(this).stop();
        $(this).prev().prev().prev().removeAttr("style");
    }
    $(this).stop();
     $(this).removeAttr("style"); 
});

JS;
$this->registerJs($js);

//'id' => 'prod-update-modal',

// Pjax::end();
//Modal::begin([
//
//    'options' => [
//        'id' => 'prod-update-modal',
//        'tabindex' => false
//    ],
//'class' => 'modal modal-primary',
//'header' => '<h4 class="modal-title">创建</h4>',
//'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
//]);
//echo Select2::widget([
//    'name' => 'state_40',
//    'data' => [1 => "First", 2 => "Second", 3 => "Third", 4 => "Fourth", 5 => "Fifth"],
//    'options' => ['placeholder' => 'Select a state ...'],
//    'pluginOptions' => [
//        'allowClear' => true
//    ],
//]);
//Modal::end();

//$requestUrl = Url::toRoute(create);
//查看
$js = <<<JS
jQuery('.activity-view-link').on('click',function() {
    $('.document-nav-form').remove();
    $.get(
        '/prod/prodinst/view',          
        {
            id: $(this).data('prod-id'),
            prod_spec_id: $(this).data('prod-spec-id'),
            prod_spec_name: $(this).data('prod-spec-name'),
            prod_floor: $(this).data('floor'),
            prod_housenumber: $(this).data('housenumber'),
            prod_manger_name: $(this).data('prod_manger_name'),
            prod_tel: $(this).data('prod_tel')
            
             
        },
        function (data) {
            $('#view-modal').find('.modal-dialog').html(data);
            //$('#view-modal').modal();
        }  
    );
});
JS;
$this->registerJs($js);



Modal::begin([
    'id' => 'view-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">查看</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();


//变更扶负责人
$js = <<<JS

jQuery('.activity-modify-uesr-link').on('click',function() {
    $('.document-modify-uesr-form').remove();
    $.get(
        '/prod/prodinst/modifyuser',
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url')
        },
        function (data) {

            $('#modify-uesr-modal').find('.modal-dialog').html(data);


        }
    );
});
JS;
$this->registerJs($js);

Modal::begin([
    'id' => 'modify-uesr-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">修改负责人</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();





$js = <<<JS
jQuery('.a-view-link').on('click',function() {
    $('.document-nav-form').remove();
    $.get(
        '/prod/prodinst/view',
        {
            id: $(this).data('prod-id'),
            prod_spec_id: $(this).data('prod-spec-id'),
            prod_spec_name: $(this).data('prod-spec-name')
        
        },
        function (data) {
            $('#a-view-modal').find('.modal-dialog').html(data);
            //$('#view-modal').modal();
        }
    );
});
JS;
$this->registerJs($js);


Modal::begin([
    'id' => 'a-view-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">查看</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();



Modal::begin([
    'id' => 'update-prod-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">' .  $prodSpecName . '</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

Modal::begin([
    'id' => 'create-prod-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">' .  $prodSpecName . '</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();


//业务2部弹窗
Modal::begin([
    'id' => 'created-prod-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">' .  $prodSpecName . '</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

?>